package com.kly.user.db.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.google.common.collect.Maps;
import com.kly.user.db.dao.UserAlbumsContentDao;
import com.kly.user.db.entity.UserAlbumsContentEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: yujianfu
 * Date: 2023-05-22
 * Time: 10:46:07.404
 */

@Repository
public class UserAlbumsContentDaoImpl extends AbstractBaseMapper<UserAlbumsContentEntity>
        implements UserAlbumsContentDao {

    @Override
    public int batchInsert(List<UserAlbumsContentEntity> list) {
        return getSqlSession().insert(this.getStatement("batchInsert"), list);
    }

    @Override
    public int deleteByAlbumCode(String albumCode) {
        return getSqlSession().delete(this.getStatement("deleteByAlbumCode"), albumCode);
    }

    @Override
    public int deleteByImageCode(String imageCode) {
        return getSqlSession().delete(this.getStatement("deleteByImageCode"), imageCode);
    }

    @Override
    public List<UserAlbumsContentEntity> selectByUserCode(String userCode, Integer type) {
        Map<String, Object> map = new HashMap<>();
        map.put("userCode", userCode);
        map.put("type", type);
        return getSqlSession().selectList(this.getStatement("selectByUserCode"), map);
    }

    @Override
    public List<UserAlbumsContentEntity> selectByAlbumCode(String albumsCode) {

        return getSqlSession().selectList(this.getStatement("selectByAlbumCode"), albumsCode);
    }

    @Override
    public List<UserAlbumsContentEntity> selectSortByAlbumCode(String albumsCode) {
        return getSqlSession().selectList(this.getStatement("selectSortByAlbumCode"), albumsCode);
    }



    @Override
    public UserAlbumsContentEntity selectByImageCode(String imageCode) {

        return getSqlSession().selectOne(this.getStatement("selectByImageCode"), imageCode);
    }

    @Override
    public List<UserAlbumsContentEntity> selectByUserCodeAndImageCode(Map<String, Object> map) {
        return getSqlSession().selectList(this.getStatement("selectByUserCodeAndImageCode"), map);
    }

    @Override
    public List<UserAlbumsContentEntity> queryImagesByAlbumTypes(List<String> userCodes, List<Integer> albumTypes){
        final HashMap<String, Object> params = Maps.newHashMap();
        params.put("list", userCodes);
        params.put("albumTypes", albumTypes);
        return getSqlSession().selectList(this.getStatement("queryImagesByAlbumTypes"), params);
    }
}